<?php $this->import('Header') ?>
	<div style="height: 10px;"></div>
	<div class="well">
		<div class="tab-content">
			<form>
				<span>标签名称：</span>
				<span><input name="tagName" value="<?php echo $tagName ?>" /></span>
				<button type="submit" class="btn">搜索</button>
			</form>
			<table class="table">
				<tr>
					<th>TagId</th>
					<th>标签名称</th>
					<th>排序</th>
					<th>是否热门</th>
					<th>添加时间</th>
					<th>操作</th>
				</tr>
				<?php foreach ($tags as $tag) { ?>
				<tr>
					<td><?php echo $tag['TagId']  ?></td>
					<td><?php echo $tag['TagName']  ?></td>
					<td><?php echo $tag['Sort']  ?></td>
					<td><?php echo $tag['IsHot'] ? '<span style="color: red;">是</span>' : '<span style="color: #c8c8cb">否</span>'  ?></td>
					<td><?php echo date('Y-m-d H:i:s', $tag['CreateTime'])  ?></td>
					<td>
						<a href="/Tag/Edit?tagId=<?php echo $tag['TagId'] ?>">编辑</a>
						<a href="javascript:;" onclick="delTag(<?php echo $tag['TagId'] ?>)">删除</a>
					</td>
				</tr>
				<?php } ?>
			</table>
			<?php \Controller\UC\Pager::instance()->run(array('pager' => $pager)) ?>
		</div>
	</div>
<?php $this->import('Footer') ?>
<script>
	function delTag(tagId) {
		if (!confirm('确定要删除这个标签吗？')) {
			return;
		}
		$.ajax({
			url: '/Ajax/Tag/delTag?stmp=' + new Date().toString(),
			type: 'post',
			dataType: 'json',
			data: {tagId: tagId},
			success: function(d) {
				if (!d.error) {
					window.location.reload();
				}
			}
		});
	}
</script>